Day 1: Concepts and a basic workflow
September 16, 2023
. . .
Git is a huge topic because and git is very powerful. Most of the things are best to learn as you need them.
Get started with simple workflows. Learn the rest as you need it.
Did anyone have problems with the workshop preparation?
Two examples in which proper version control can be a life/time saver
Complete and long-term history of every file in your project
Open source and free to use version control software
Quasi standard for software development
A whole universe of other software and services around it
For projects with mainly text files (e.g. code, markdown files, …)
Basic idea: Take snapshots (commits) of your project over time
A project version controlled with Git is a Git repository (repo)
Git is a distributed version control system
After you installed it there are different ways to interact with the software.
Using Git from the terminal
➕ Most control
➕ A lot of help/answers online
➖ You need to use terminal 😱
A Git GUI is integrated in most (all?) IDEs, e.g. R Studio, VS Code
➕ Easy and intuitive
➕ Stay inside IDE
➖ Different for every program
Standalone Git GUI software, e.g. Github Desktop
➕ Easy and intuitive
➕ Nice integration with Github
➖ Switch programs to use Git
Tip
Have a look at the website where you find How-To guides for the other methods as well.
git init,git add,git commit,git push
.git folder to your project
Git detects any changes in the working directory
Stage file to be part of the next commit (snapshot)
git addAdd some recipes to your cook book
See here for more details but some general rules:
✔️
Use remote repos (on a server) to synchronize, share and collaborate
Remote repos can be private (you + collaborators) or public (visible to anyone)
git pushPublish your cook book on Github (please make it public)
git init: Initialize a git repository
.git folder to your working directorygit add: Add files to the staging area
git commit: Take a snapshot of your current project version
git push: Push new commits to the remote repository
git log, git checkout, git revert
git checkoutgit revert to revert specific commitsRevert a part of your recipe
Ignore files, publish your projects
.gitignore.gitignore file to list files/folders that you don’t want to track with git.gitignoreCreate a file with the name .gitignore in working directory
Add all files and directories you want to ignore to the .gitignore file
*.html # ignore all .html files
*.pdf # ignore all .pdf files
debug.log # ignore the file debug.log
build/ # ignore all files in subdirectory buildSee here for more ignore patterns that you can use.
Github/Gitlab are a good way to publish and share your work.
You can increase the quality/complexity of your repo by
Questions?
Basic Git workflow